#include<stdio.h>  
#include<string.h>
/*耦合*/
/*结构体的定义*/
struct Person
{
   int age;
    char name[20];
    int weight;
    char phone[12] ; 
    char address[20];
     
};
/*字节对齐*/


/**/


/*传入参数：不改变实参*/
void printIofo(struct Person *per)
{   
    int size = sizeof(per);
    printf("size = %d\n",size);

    printf("name:%s,age:%d,weight:%d,address:%s,phone:%s\n",per->name,per->age,per->weight,per->address,per->phone);
}
void printInfo(const struct Person*per,int numSize)
{   
    
    for(int idx = 0;idx < numSize; idx++)
    {
        printf("name:%s,age:%d\n",per[idx].name,per[idx].age);
    }
}
void printArray(char **str,int numsize)
{
    for(int idx = 0;idx < numsize;idx++)
    {
        printf("%s\n",*(str+idx));
    }

}

/*主函数*/
int main()
{   
    #if 0
    struct Person per1;
    /*结构体的内存大小*/
    int length = sizeof(per1);
    /*清除脏数据,初始化*/
    bzero(&per1,length);
    printf("length = %d\n",length);

    /*结构体的赋值*/
    per1.age = 22;
    /*数组名是地址*/
    //per1.name = ""

    strcpy(per1.name,"zhangsan");
    per1.weight = 70;
    strcpy(per1.address,"jiangsuNanjing");
    strcpy(per1.phone,"025-8xxxx");

    printIofo(&per1);
    printf("name:%s,\t age:%d,weight:%d\n",per1.name,per1.age,per1.weight);
#endif
#if 0
    char * array[5] = {"zhangsan","lisi","wangwu","mazi","luoxiang"};

    printf("array[0]:%s\t*(array+0):%s\n",array[0],*(array+0));
    printf("array[1]:%s\t*(aray+1):%s\n",array[1],*(array+0));
    
    printf("array[0]:%c\t*(array + 0):%s\n",array[0][2],*(array+0));

    int length = sizeof(array)/sizeof(array[0]);
    printArray(array,length);
    #endif
    #if 0
    for(int end = length;end > 0;end--)
    {
        for(int begin =1;begin < end;begin++)
        {
         if (strcmp[begin - 1] > array[begin])
         {
             char *temp = array[begin - 1];
                array[begin - 1] = array[begin];
                array[begin] = temp;
         }
        }
    }
    for(int i =0;i<length;i++)
    {
    printf("%s\t",array[i]);
    }
    printf(" \n");
    #endif
    #if 1
    struct Person array[5];
    bzero(array,sizeof(array));

    array[0].age = 20;
    strcpy(array[0].name,"zhangsan");

    array[1].age = 20;
    strcpy(array[1].name,"zhangsan");

    array[2].age = 20;
    strcpy(array[2].name,"zhangsan");

    for(int idx = 0;idx<3;idx++)
    {
        printf("array[%d].age = %d,array[%d].name = %s\n",idx,array[idx].age,idx,array[idx].name);
    }
    printInfo(array,3);
    #endif
}